package org.rency.ues.common.enums;

public enum EncryptType {
	RSA("RSA"),
	DES("DES"),
	SHA("SHA"),
	MD5("MD5"),
	DSA("DSA"),
	CMS("CMS"),
	;
	
	private String code;
	
	EncryptType(String code){
		this.code = code;
	}
	
	public String getCode(){
		return this.code;
	}
	
	public static EncryptType get(String code){
		EncryptType[] values = EncryptType.values();
		for(EncryptType en : values){
			if(code.toUpperCase().equals(en.getCode())){
				return en;
			}
		}
		return null;
	}

	/**
	 * 加密方式是否有效
	 * @param enType
	 * @return
     */
	public static boolean isValid(String enType){
		if(enType == null){
			return false;
		}
		if(EncryptType.get(enType) == null){
			return false;
		}
		return true;
	}
	
}
